<template>
  <!-- 添加或修改小区信息对话框 -->
  <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body v-drag-fullscreen>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-form-item label="当前账期" prop="fiscalPeriod">
        <el-date-picker
          v-model="form.fiscalPeriod"
          type="month"
          value-format="yyyy-MM"
          placeholder="选择月">
        </el-date-picker>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import { initCurrentFiscalPeriod } from "@/api/property/community";
  export default {
    name: "initFiscalPeriod",
    data(){
      return{
        open:false,
        title:'初始化当前账期',
        form:{},
        rules:{
          fiscalPeriod: [
            { required: true, message: "当前账期不能为空", trigger: "blur" },
          ],
        }
      }
    },
    methods:{
      show(option){
        this.form = option.form
        this.open = true
      },
      cancel(){
        this.open = false
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            initCurrentFiscalPeriod(this.form).then(response => {
              this.msgSuccess("初始化账期成功");
              this.open = false;
              this.$emit("ok")
            });
          }
        });
      },
    }
  }
</script>

<style scoped>

</style>
